package com.huangguolin.cloud.share.control;

import com.huangguolin.cloud.mybatis.entity.PtShareEntity;
import com.huangguolin.cloud.mybatis.flexigrid.PadingRstEntity;
import com.huangguolin.cloud.mybatis.flexigrid.PagingEntity;
import com.huangguolin.cloud.role.entity.SearchRoleEntity;
import com.huangguolin.cloud.share.service.ShareService;
import com.huangguolin.cloud.spring.control.BaseController;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/share")
public class ShareController  extends BaseController {

    private Logger logger = LogManager.getLogger(this.getClass());

    @Resource
    private ShareService shareService;

    @RequestMapping("/sharePage")
    public String sharePage(){
        return "share/sharePage";
    }

    @RequestMapping("/queryShareListByPage")
    @ResponseBody
    public PadingRstEntity<PtShareEntity> queryShareListByPage(SearchRoleEntity search, PagingEntity paging){

        logger.info(search);
        logger.info(paging);
        PadingRstEntity<PtShareEntity> ptShareEntityntityPadingRstEntity = shareService.queryShareListByPage(search,paging);
        return ptShareEntityntityPadingRstEntity;
    }

    //文件删除控制层
    @RequestMapping("/deleteFile")
    @ResponseBody
    public String deleteFile(@RequestParam("fileUuid")String fileUuid) {
        shareService.deleteFile(fileUuid);
        return successJSON("delete.file.success");
    }
}
